package com.mc.lp.database.entity.helper;

import org.apache.log4j.Logger;

import com.mc.lp.database.entity.RecommendationEntity;
import com.mc.lp.database.entity.type.RecordType;
import com.mc.lp.shared.vo.RecommendationVO;
/*
 * @author aphanda
 * @date Dec 29, 2014
 * @time 11:18:11 PM
 */
import com.mc.lp.shared.vo.SearchCriteriaVO;

public class RecommendationEntityHelper implements IEntityHelper<RecommendationEntity, RecommendationVO> {
	Logger log=Logger.getLogger(RecommendationEntityHelper.class);

	@Override
	public RecommendationVO getVO(RecommendationEntity entity) {
		RecommendationVO vo = new RecommendationVO();
		
		vo.setId(entity.getId());

		SearchCriteriaVO pageDataVO = new SearchCriteriaVO();
		pageDataVO.setGradeId(entity.getGradeId());
		pageDataVO.setStudentEntityId(entity.getStudentEntity());
		//pageDataVO.setYear(Long.toString(entity.getYear()));
		pageDataVO.setTermId(entity.getTermId());
		pageDataVO.setRecordType(entity.getRecordType().name());
		vo.setSearchCriteria(pageDataVO);
		vo.setRecommendationText(entity.getRecommendation());
		vo.setRecommendationtitle(entity.getRecommendationTitle());
		return vo;
	}

	@Override
	public RecommendationEntity getEntity(RecommendationVO vo) {
		RecommendationEntity en = new RecommendationEntity();
		setEntity(vo, en);
		return en;
	}

	@Override
	public void setEntity(RecommendationVO vo, RecommendationEntity entity) {
		if(vo.getId() != null){
			entity.setId(vo.getId());
		}
		entity.setGradeId(vo.getSearchCriteria().getGradeId());
		entity.setTermId(vo.getSearchCriteria().getTermId());
		entity.setStudentEntity(vo.getSearchCriteria().getStudentEntityId());
		entity.setRecordType(RecordType.getType(vo.getSearchCriteria().getRecordType()));
		entity.setRecommendation(vo.getRecommendationText());
		entity.setRecommendationTitle(vo.getRecommendationtitle());
	}
}